package com.ywl.designpattern.interpreter;

public class InterpreterPatternDemo {
    public static void main(String[] args) {
        // 构建表达式: 5 + (10 - 3)
        Expression expression = new AddExpression(
            new NumberExpression(5),
            new SubtractExpression(
                new NumberExpression(10),
                new NumberExpression(3)
            )
        );

        // 解释并计算结果
        int result = expression.interpret();
        System.out.println("5 + (10 - 3) = " + result);
    }
}
